package tset1;

public class Count {
    private static int count;
    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();
        Thread t1=new Thread(()->{
            for (int i = 0; i < 50000; i++) {
                synchronized (locker){
                    count++;//自增5w次
                }
            }
        }," T1");
        Thread t2=new Thread(()->{
            for (int i = 0; i < 50000; i++) {
                synchronized (locker){
                    count++;//自增5w次
                }
            }
        },"T1");
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("count=" + count);
    }
}
